#pragma once
#include <QDialog>
#include <QMessageBox>

#include "widgets.h"

class QHBoxLayout;
class QVBoxLayout;
class QPushButton;
class SImageButton;
class S_WIDGETS_EXPORT SPopupWindow : public QDialog {
 public:
  SPopupWindow(QWidget* parent = nullptr);
  void setTitle(const QString&);
  QPushButton* addBtn(QMessageBox::StandardButton btnType, const QString&);
  QVBoxLayout* contentLayout() const { return m_contentLayout; }
  SImageButton* getBtnClose() { return m_btnClose; }
  QString getTitle() { return m_title; }
  QPushButton* changeBtnName(QMessageBox::StandardButton btnType,
                             const QString&);

 protected:
  virtual void keyPressEvent(QKeyEvent*) override;
  virtual void mousePressEvent(QMouseEvent* event) override;
  virtual void mouseReleaseEvent(QMouseEvent* event) override;
  virtual void mouseMoveEvent(QMouseEvent* event) override;
  virtual void paintEvent(QPaintEvent* event) override;
  virtual void resizeEvent(QResizeEvent*) override;

 protected:
  QString m_title;
  QHBoxLayout* m_btnLayout = nullptr;
  QVBoxLayout* m_contentLayout = nullptr;
  SImageButton* m_btnClose = nullptr;
  QPushButton* m_btnOK = nullptr;
  QPushButton* m_btnCancel = nullptr;
  QPushButton* m_btnApply = nullptr;
  bool m_dragging = false;
  int m_nTitleHeight = 24;
};